package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.domain.TravelCommend;
import cn.wolfcode.luowowo.article.query.TravelCommendQuery;
import cn.wolfcode.luowowo.article.service.IStrategyDetailService;
import cn.wolfcode.luowowo.article.service.ITravelCommendService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/travelCommend")
@Controller
public class TravleCommendController {

    @Reference
    private ITravelCommendService travelCommendService;
    @Reference
    private IStrategyDetailService strategyDetailService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")TravelCommendQuery qo){
        model.addAttribute("pageInfo",travelCommendService.query(qo));
        model.addAttribute("details",strategyDetailService.list());
        return "travelCommend/list";
    }


    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(TravelCommend travelCommend){
        AjaxResult result = new AjaxResult();
        try {
            travelCommendService.saveOrUpdate(travelCommend);
        }catch (Exception e){
            e.printStackTrace();
             result.setMsg("保存或编辑失败");
        }
        return new AjaxResult(true,"保存或编辑成功");
    }
}
